package com.kaifamiao.custom;

/**
 * 异常转译
 * 通过捕获一个异常，再抛出另外一个异常，实现对原异常的"翻译"
 */
public class MathTest {
	
	public long divide( int a , int b ) {
		int c ;
		try {
			c = a / b ;
		} catch( ArithmeticException cause ) {
			throw new MathException( "除数不可以为零" , cause );
		}
		return c ;
	}
	
	public static void main(String[] args) {
		MathTest m = new MathTest();
		long result = m.divide( 5 , 0 );
		System.out.println( result );
	}

}
